package com.ruoyi.web.controller.app.pay.util;

import java.io.UnsupportedEncodingException;

public class Mds5 {
	
	public final static String   key="C80FA1E3591DF0C3"; //加密唯一key
	public static String GetMd5(String str){
		return getMD5(str.getBytes()).substring(8, 24);
	}
	public static String Get32(String str) throws UnsupportedEncodingException{
		return getMD5(str.getBytes("UTF-8"));
	}

	
	private static String getMD5(byte[] source) {
		  String s = null;
		  char hexDigits[] = {       // ??��?��??�????�???��?? 16 �???�表示�??�?�?
		     '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',  'e', 'f'}; 
		   try
		   {
		    java.security.MessageDigest md = java.security.MessageDigest.getInstance( "MD5" );
		    md.update( source );
		    byte tmp[] = md.digest();          // MD5 ???计�??�???????�?�? 128 �??????��?��?��??
		                                                // ??��?????表示就�?? 16 �?�????
		    char str[] = new char[16 * 2];   // �?�?�??????? 16 �???�表示�??�?�?使�?�两�?�?�?�?
		                                                 // ???以表示�?? 16 �???��??�? 32 �?�?�?
		    int k = 0;                                // 表示�???��?????�?对�?????�?�?�?�?
		    for (int i = 0; i < 16; i++) {          // �?�?�?�?�????�?�?�?�? MD5 ???�?�?�?�????
		                                                 // �???��?? 16 �???��??�????�????
		     byte byte0 = tmp[i];                 // ???�? i �?�????
		     str[k++] = hexDigits[byte0 >>> 4 & 0xf];  // ???�????�?�? 4 �??????��??�????, 
		                                                             // >>> 为�?��????�移�?�?�???��??�?起�?�移
		     str[k++] = hexDigits[byte0 & 0xf];            // ???�????�?�? 4 �??????��??�????
		    } 
		    s = new String(str);                                 // ??��?????�????�????为�??�?�?

		   }catch( Exception e )
		   {
		    e.printStackTrace();
		   }
		   return s;
		 }



}
